<?php if(isset($isInsert) && $isInsert){
?>
<script>
	ajax('listContent','<?php echo $this->params['controller']?>/lists');
	closeBox('addContent','mainContent');
</script>
<?php
}
else{
?>
<fieldset>
    <legend><?php _resource('add '.$this->params['controller']);?></legend>
<center><div id="message">&nbsp;</div></center>
<?php if($this->Session->read('message')){
	echo '<script>showMessage("addContent","'.$this->Session->read('message').'");</script>';
	$this->Session->delete('message');	
	}?>
<?php if($this->Session->read('error')){
	echo '<script>showMessage("addContent","'.$this->Session->read('error').'",1);</script>';
	$this->Session->delete('error');
}?>
    <form id="adminForm" name="adminForm" method="post" action="<?php echo $this->params['controller'] ?>/add" onsubmit="onFormSubmit();return false;">
    
	<table border="0" class="form" style="width:100%">        
		
		<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('name') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->input($uses[0].'.name',array('class'=>'input','label'=>'','size'=>60,'maxlength'=>255));?></td>           
        </tr>      
		<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('code') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->input($uses[0].'.code',array('class'=>'input','label'=>'','size'=>60,'maxlength'=>255));?></td>           
        </tr>  
        
        
        <?php if(count($priors)>0){?>
 		<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('priority') ?>
       		
       		</td>
       		<td align="left">
       			<?php echo $this->Form->input($uses[0].'.priority_id', array('type'=>'select','options'=>$priors,'default'=>$defaultPriorId,'empty'=>false,"class"=>"inputbox","label"=>"","error"=>""));?>
       		</td>           
        </tr>   
        <?php }?>
        <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('description') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->textarea($uses[0].'.description',array('class'=>'','label'=>'','error'=>'','cols'=>120,'rows'=>10));?></td>           
        </tr> 

<?php if(count($fields)>0){?>
 	<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('field') ?>
       		
       		</td>
       		<td align="left"><?php foreach($fields as $k=>$v){
			echo $this->Form->checkbox($uses[0].'.fields.'.$v['Field']['id'],array('hiddenField'=>false,'value'=>$v['Field']['id'])).$v['Field']['name'].'<br />';
		}?></td>           
        </tr>   
        <?php }?>

        
        <?php if(isset($users)>0){?>
 	
 	<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('User join:') ?>
       		
       		</td>
       		<td align="left">
       			<?php 
       			$userArr=array();
        foreach($users as $k=>$v){
        	$userArr[$v['User']['id']]=$v['User']['name'];
			echo $this->Form->checkbox($uses[0].'.users.'.$v['User']['id'],array('hiddenField'=>false,'value'=>$v['User']['id'])).$v['User']['username'].'<br />';
		}
       			?>
       		</td>           
        </tr> 
        
        <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('QA:') ?>
       		
       		</td>
       		<td align="left">
       			<?php 
       			$userArr=array();
        foreach($users as $k=>$v){
        	$userArr[$v['User']['id']]=$v['User']['name'];
			echo $this->Form->checkbox($uses[0].'.qa.'.$v['User']['id'],array('hiddenField'=>false,'value'=>$v['User']['id'])).$v['User']['username'].'<br />';
		}
       			?>
       		</td>           
        </tr>   
        
        <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('Manager:') ?>
       		
       		</td>
       		<td align="left">
       			<?php 

			//echo $this->Form->radio($uses[0].'.manager',$userArr,array('legend'=>'','value'=>'','separator'=>'<br />'));
        foreach($users as $k=>$v){
        	$check='';
        	if($this->data[$uses[0]]['manager']==$v['User']['id'])$check="checked=true";
			echo '<input '.$check.' type="radio" value="'.$v['User']['id'].'" id="ProjectManager'.$v['User']['id'].'" name="data[Project][manager]" />
			<label for="ProjectManager'.$v['User']['id'].'">'.$v['User']['username'].'</label><br />';
		 }
       			?>
       		</td>           
        </tr>   
        <?php }?>
        
       
 	
        
            
	</table>
	<center>
    <div style="width:130px">
          <div class="button"><a onclick="onFormSubmit()" href="javascript:;" title="<?php echo _resource('save') ?>"  > <span class="icon-32-save"> </span></a> </div>         
          <div class="button"><a onclick="resetForm('adminForm')" href="javascript:;" title="<?php echo _resource('reset') ?>"  > <span class="icon-32-back"> </span></a> </div>
          <div class="button"><a onclick="deactivateEditors();closeBox('addContent','mainContent')" href="javascript:;" title="<?php echo _resource('close') ?>"  > <span class="icon-32-cancel"> </span></a> </div>
    </div>
    </center>
      </form>
</fieldset>


<script>
	<?php if(isset($isInsert) && $isInsert){
		echo 'ajax("listContent","'.$this->params['controller'].'/lists");';
	}?>
	function onFormSubmit(){
		var content = ckeditor.getData();
		deactivateEditors();
		$('#<?php echo $uses[0].'Description' ?>').html(content);
		submitForm('adminForm','addContent');
	}	
	activateEditor("<?php echo $uses[0].'Description' ?>");

scrollTopTo('addContent');
</script>
<?php }?>